<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml" xmlns:v-demo="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .router-link-active {
            color:#f00;
        }
        pre {
            font-family: sans-serif;
            font-size: 1em;
            line-height:1.5em;
        }

    </style>
</head>
<body>
<div id="app">
    <ul>
        <li>
            <router-link to="/">/</router-link>
        </li>
        <li>
            <router-link to="/next">/next</router-link>
        </li>
    </ul>
    <router-view></router-view>
</div>
</body>

<script src="../../../vender/vue@2.4.2.js"></script>
<script src="../../../vender/vue-router@2.7.0.js"></script>

<script>
    const Home={template:'<div>Home.</div>'};
    const Next={template:'<div>Next.</div>'};

    const router=new VueRouter({
        routes:[
            {path:'/',component:Home},
            {path:'/next',component:Next}
        ]
    });

    router.beforeEach((to,from,next)=>{
        console.info('全局路由钩子-beforeEach:',this);//Window
        console.log(to);
        console.log(from);
        next();
        /*next 参数
         * 无参数 完成此导航
         * 字符中 跳转路由
         * false 终止当前导航
         * */
    });

    const app=new Vue({
        el:'#app',
        router
    });

</script>
</html>